package com.hyper_yang.javase.supplement.learnInstanceInit;

public class Person {
    {
//        System.out.println(age); ❌ 可以对比下类初始化下的静态代码块
        System.out.println("Person普通代码块2");
    }
    String name;
    int age = 20;
    {
        System.out.println(name);
    }

    public Person() {
        super();
        System.out.println("Person无参构造");
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Person有参构造");
    }

    {
//        System.out.println(age); ✔
        System.out.println("Person普通代码块1");
    }
    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
